const String jsonKeyChatBeanChatId = 'chat_id';
const String jsonKeyChatBeanName = 'name';
const String jsonKeyChatBeanAvatar = 'avatar';
const String jsonKeyChatBeanMessage = 'message';
const String jsonKeyChatBeanUpdateTime = 'update_time';
const String jsonKeyChatBeanUserId = 'user_id';

class ChatBean {
  String? chatId;
  String? name;
  String? avatar;
  String? message;
  String? updateTime;
  String? userId;

  ChatBean({
    this.chatId, //md5(对方id+自己手机号)
    this.name,
    this.avatar,
    this.message,
    this.updateTime,
    this.userId,
  });
  ChatBean.fromJson(dynamic json) {
    chatId = json[jsonKeyChatBeanChatId]?.toString();
    name = json[jsonKeyChatBeanName]?.toString();
    avatar = json[jsonKeyChatBeanAvatar]?.toString();
    message = json[jsonKeyChatBeanMessage]?.toString();
    updateTime = json[jsonKeyChatBeanUpdateTime]?.toString();
    userId = json[jsonKeyChatBeanUserId]?.toString();
  }
  dynamic toJson() {
    final data = <String, dynamic>{};
    data[jsonKeyChatBeanChatId] = chatId;
    data[jsonKeyChatBeanName] = name;
    data[jsonKeyChatBeanAvatar] = avatar;
    data[jsonKeyChatBeanMessage] = message;
    data[jsonKeyChatBeanUpdateTime] = updateTime;
    data[jsonKeyChatBeanUserId] = userId;
    return data;
  }
}

const String jsonKeyMessageBeanMessageId = 'message_id';
const String jsonKeyMessageBeanChatId = 'chat_id';
const String jsonKeyMessageBeanFromId = 'from_id';
const String jsonKeyMessageBeanFromName = 'from_name';
const String jsonKeyMessageBeanToId = 'to_id';
const String jsonKeyMessageBeanToName = 'to_name';
const String jsonKeyMessageBeanAvatar = 'avatar';
const String jsonKeyMessageBeanMessage = 'message';
const String jsonKeyMessageBeanUpdateTime = 'update_time';

class MessageBean {
  String? messageId; //md5(时间戳)
  String? chatId;
  String? fromId;
  String? fromName;
  String? toId;
  String? toName;
  String? avatar;
  String? message;
  String? updateTime;

  MessageBean({
    this.messageId,
    this.chatId,
    this.fromId,
    this.fromName,
    this.toId,
    this.toName,
    this.avatar,
    this.message,
    this.updateTime,
  });
  MessageBean.fromJson(dynamic json) {
    messageId = json[jsonKeyMessageBeanMessageId]?.toString();
    chatId = json[jsonKeyMessageBeanChatId]?.toString();
    fromId = json[jsonKeyMessageBeanFromId]?.toString();
    fromName = json[jsonKeyMessageBeanFromName]?.toString();
    toId = json[jsonKeyMessageBeanToId]?.toString();
    toName = json[jsonKeyMessageBeanToName]?.toString();
    avatar = json[jsonKeyMessageBeanAvatar]?.toString();
    message = json[jsonKeyMessageBeanMessage]?.toString();
    updateTime = json[jsonKeyMessageBeanUpdateTime]?.toString();
  }
  dynamic toJson() {
    final data = <String, dynamic>{};
    data[jsonKeyMessageBeanMessageId] = messageId;
    data[jsonKeyMessageBeanChatId] = chatId;
    data[jsonKeyMessageBeanFromId] = fromId;
    data[jsonKeyMessageBeanFromName] = fromName;
    data[jsonKeyMessageBeanToId] = toId;
    data[jsonKeyMessageBeanToName] = toName;
    data[jsonKeyMessageBeanAvatar] = avatar;
    data[jsonKeyMessageBeanMessage] = message;
    data[jsonKeyMessageBeanUpdateTime] = updateTime;
    return data;
  }
}
